package edu.upf.da.p2p.sm.client.manager;

import java.util.List;
import java.util.Vector;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import edu.upf.da.p2p.objects.DescriptionContent;
import edu.upf.da.p2p.sm.P2PMessage;
import edu.upf.da.p2p.sm.P2PMessageListener;
import edu.upf.da.p2p.sm.client.message.SearchResult;

public class SearchResultManager extends P2PMessageListener {

	private static final Log log = LogFactory.getLog(SearchResultManager.class);
	private Vector<DescriptionContent> resultados;

	public SearchResultManager() {
		resultados = new Vector<DescriptionContent>();
	}

	public List<DescriptionContent> getResults() {
		return resultados;
	}

	public void processMessage(P2PMessage pkt) {
		SearchResult sr = (SearchResult) pkt;
		resultados.addAll(sr.getResult());
		if(log.isTraceEnabled()){
			log.trace("Se han recibido resultados para la busqueda numero: "+sr.getSearchId()+".");
		}
	}

}
